package com.cong.reflection;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.stream.Stream;

public class Reflection {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Class<?> clazz = Class.forName("com.cong.reflection.Student");
        System.out.println(clazz);
        System.out.println(clazz.getField("name"));
        Method hello = clazz.getDeclaredMethod("hello");
        Constructor<?>[] constructors = clazz.getConstructors();
        Stream.of(constructors).forEach(c -> {
          c.setAccessible(true);
        });
    }
}
